CC      = gcc
PROC    = proc
AR      = ar cr
LINKER  = $(CC) 
LINT    = lint -c
RM      = /bin/rm -f
CP      = /bin/cp -i
MV      = /bin/mv

INCLUDE = -I. 
LIBPATH = -L. 
LIBFILE	= -lrt -lpthread -lnsl

PROJECT  =    SOA_CLIENT_V001

APP_ROOT =  ./bin/


#source file list
INCLUDE  +=
SRCPP    = global.c myfunc.c process.c main.c conn.c

SRCC     =
SRCPROC  =


OBJS         =  $(SRCPP:.cpp=.o) $(SRCC:.c=.o) $(SRCPROC:.pc=.o) $(SR_SHARE_MAKE:.cpp=.o)
OBJS_LINK    =  $(SRCPP:.cpp=.o) $(SRCC:.c=.o) $(SRCPROC:.pc=.o) $(SR_SHARE_LINK:.cpp=.o) 
OBJS_SO      =  $(SRCPP:.cpp=.oso) $(SRCC:.c=.oso) $(SRCPROC:.pc=.oso)
OBJS_SO_LINK =  $(SRCPP:.cpp=.oso) $(SRCC:.c=.oso) $(SRCPROC:.pc=.oso)

CFLAGS       =  -ggdb -Wall $(INCLUDE) $(LIBPATH) $(OSFLAGS)
CFLAGS_SO    =  -Wall -fPIC -ggdb $(INCLUDE) $(LIBPATH) $(OSFLAGS)





.SUFFIXES: .a .o .oso .cpp .pc .c

.cpp.o:
	@echo "              "
	@echo "C++ ..."
	$(CC) -c $(CFLAGS) $*.cpp

.cpp.oso:
	@echo "              "
	@echo "Dynamic C++ ..."
	$(CC) -c  $(CFLAGS_SO) $*.cpp -o $@

.c.o:
	@echo "              "
	@echo "C ..."
	$(CC) -c $(CFLAGS) $*.c 

.c.oso:
	@echo "              "
	@echo "Dynamic C ..."
	$(CC) -c  $(CFLAGS_SO) $*.c -o $@

.pc.o:
	@echo "              "
	@echo "PRO C/C++ ... "
	$(PROC) iname=$*.pc code=cpp oname=$*.cpp $(PROCFLAGS) 
	$(CC) -c $(CFLAGS) $*.cpp

.pc.oso:
	@echo "              "
	@echo "PRO C/C++ ... "
	$(PROC) iname=$*.pc code=cpp oname=$*.cpp $(PROCFLAGS) 
	$(CC) -c  $(CFLAGS_SO) $*.cpp -o $@



VERSION_DATE=`date '+%y%m%d'`

all: $(PROJECT) 

$(PROJECT): $(OBJS)
	$(CC) -o $(PROJECT)_B$(VERSION_DATE) $(OBJS_LINK) $(CFLAGS) $(LIBFILE)

run:
	./$(PROJECT)_B$(VERSION_DATE) 

kill:
	pkill -USR2 $(PROJECT)_B
clean:
	@$(RM) *.o *.oso 
	@$(RM) $(PROJECT)_B$(VERSION_DATE) $(PROJECT_SO)

DATA=`date '+%m%d%y_%H%M%S'`
bak:clean
	tar -cvf bak/gis_$(DATA).tar *.*

check:
	$(LINT) $(CFLAGS) $(SRCPP)

depend:
	makedepend $(CFLAGS) $(SRCPP) 

grep:
	ps -ef|grep SOA

# DO NOT DELETE THIS LINE -- make depend depends on it.
